/**
 * Globals.java
 *
 * This class provides a singleton which is used to hold global items.
 *
 *    Copyright 2011 Bravo369.org
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @author = mmeade
 *
 */

package org.bravo369.inflightxt.utils;

import java.util.Vector;

/**
 * Globals
 *
 * @author mmeade
 *
 */
public class Globals {
  private static Globals globals = new Globals();
  public enum SyncMode {SYNC_TO_SERVER, NO_SYNC_TO_SERVER };
  private Vector<Exitable> exitHandlers;
  public int dataRefreshRate = 1000;
  public int serverUpdateRate = 10000;
  public String apiUri = "http://bravo-369.appspot.com/api.html";
  public String currentSession = "";
  public Repository repository = new Repository();
  public String authKey = "AZZT12212056";
  public SyncMode mode = SyncMode.SYNC_TO_SERVER;


  private Globals() {
    exitHandlers = new Vector<Exitable>();
  }

  /**
   * The public accessor method to get the Global instance.
   *
   * @return The current instance of Globals.
   */
  public static Globals getInstance() {
    return globals;
  }

  public void addExitHandler(Exitable exitHandler) {
    exitHandlers.add(exitHandler);
  }

  public void exit() {
    for (Exitable exitHandler : exitHandlers) {
      exitHandler.onExit();
    }
  }
}

